home *** CD-ROM | disk | FTP | other *** search
- ;;; -*- Scheme -*-
-
- #|
-
- Copyright (c) 1986-91 Massachusetts Institute of Technology
-
- This material was developed by the Scheme project at the Massachusetts
- Institute of Technology, Department of Electrical Engineering and
- Computer Science. Permission to copy this software, to redistribute
- it, and to use it for any purpose is granted, subject to the following
- restrictions and understandings.
-
- 1. Any copy made of this software must include this copyright notice
- in full.
-
- 2. Users of this software agree to make their best efforts (a) to
- return to the MIT Scheme project any improvements or extensions that
- they make, so that these may be included in future releases; and (b)
- to inform MIT of noteworthy uses of this software.
-
- 3. All materials developed as a consequence of the use of this
- software shall duly acknowledge such use, in accordance with the usual
- standards of acknowledging credit in academic research.
-
- 4. MIT has made no warrantee or representation that the operation of
- this software will be error-free, and MIT is under no obligation to
- provide any services, by way of maintenance, update, or otherwise.
-
- 5. In conjunction with products arising from the use of this material,
- there shall be no use of the name of the Massachusetts Institute of
- Technology nor of any adaptation thereof in any advertising,
- promotional, or sales literature without prior written consent from
- MIT in each case.
-
- |#
-
- ;;;; Henderson-Escher picture language in Scheme
-
- (define make-rect list)
- (define origin car)
- (define horiz cadr)
- (define vert caddr)
-
- (define (coord-map rect)
- (lambda (point)
- (+vect (+vect (scale (xcor point)(horiz rect))
- (scale (ycor point)(vert rect)))
- (origin rect))))
-
- (define make-vect cons)
- (define xcor car)
- (define ycor cdr)
-
- (define make-segment cons)
- (define seg-start car)
- (define seg-end cdr)
-
- (define (+vect v1 v2)
- (make-vect (+ (xcor v1)(xcor v2))
- (+ (ycor v1)(ycor v2))))
-
- (define (scale a vect)
- (make-vect (* a (xcor vect)) (* a (ycor vect))))
-
- (define (make-picture seglist)
- (lambda (rect)
- (mapc (lambda (segment)
- (drawline ((coord-map rect) (seg-start segment))
- ((coord-map rect) (seg-end segment))))
- seglist)))
-
- (define (repeated proc n)
- (lambda (thing)
- (if (= n 0)
- thing
- ((repeated proc (-1+ n)) (proc thing)))))
-
- (define (rotate90 pict)
- (lambda (rect)
- (pict (make-rect (+vect (origin rect)(horiz rect))
- (vert rect)
- (scale -1 (horiz rect))))))
-
- (define rotate180 (repeated rotate90 2))
- (define rotate270 (repeated rotate90 3))
-
- (define (flip pict)
- (lambda (rect)
- (pict (make-rect (+vect (origin rect) (horiz rect))
- (scale -1 (horiz rect))
- (vert rect)))))
-
- (define (together pict1 pict2)
- (lambda (rect)
- (pict1 rect)
- (pict2 rect)))
-
- (define (beside pict1 pict2 a)
- (lambda (rect)
- (pict1 (make-rect (origin rect)
- (scale a (horiz rect))
- (vert rect)))
- (pict2 (make-rect (+vect (origin rect) (scale a (horiz rect)))
- (scale (- 1 a) (horiz rect))
- (vert rect)))))
-
- (define (above pict1 pict2 a)
- (rotate270 (beside (rotate90 pict1) (rotate90 pict2) a)))
-
- ;; This picture is used when there is no text capability in graphics.
-
- (define default-text-picture ; A cross
- (make-picture (list (make-segment (make-vect 0 0)
- (make-vect 1 1))
- (make-segment (make-vect 0 1)
- (make-vect 1 0)))))
-
- ;;; System dependencies
- ;;; The names to be defined are:
- ;;; screen, drawline, text-picture,
- ;;; clear-graphics, initialize-graphics,
- ;;; draw, draw-permanent.
-
- ;; Old MIT SICP Scheme implementation is contained in chipmunk.scm
- ;; Old MIT CScheme implementation is contained in bobcat.scm
- ;; Old MacScheme implementation is contained in macscheme.scm
- ;; MIT CScheme 7.1 implementation (under X) contained in cscheme.scm
-
-